<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionMailer::MailHelper</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionMailer::MailHelper 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/actionmailer/lib/action_mailer/mail_helper_rb.html">actionmailer/lib/action_mailer/mail_helper.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MailHelper.html#method-i-attachments">attachments</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>B</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MailHelper.html#method-i-block_format">block_format</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MailHelper.html#method-i-format_paragraph">format_paragraph</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="MailHelper.html#method-i-mailer">mailer</a>,
              </li>
            
              
              <li>
                <a href="MailHelper.html#method-i-message">message</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-attachments">
            
              <b>attachments</b>()
            
            <a href="MailHelper.html#method-i-attachments" name="method-i-attachments" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Access the message attachments list.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-attachments_source')" id="l_method-i-attachments_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/e2c7545cdd69376ed7e6ccb2084dda8cbd7571c2/actionmailer/lib/action_mailer/mail_helper.rb#L28" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-attachments_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionmailer/lib/action_mailer/mail_helper.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">attachments</span>
  <span class="ruby-ivar">@_message</span>.<span class="ruby-identifier">attachments</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-block_format">
            
              <b>block_format</b>(text)
            
            <a href="MailHelper.html#method-i-block_format" name="method-i-block_format" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Take the text and format it, indented two spaces for each line, and wrapped
at 72 columns.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-block_format_source')" id="l_method-i-block_format_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/e2c7545cdd69376ed7e6ccb2084dda8cbd7571c2/actionmailer/lib/action_mailer/mail_helper.rb#L5" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-block_format_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionmailer/lib/action_mailer/mail_helper.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">block_format</span>(<span class="ruby-identifier">text</span>)
  <span class="ruby-identifier">formatted</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n\r?\n/</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">paragraph</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">format_paragraph</span>(<span class="ruby-identifier">paragraph</span>)
  }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n\n&quot;</span>)

  <span class="ruby-comment"># Make list points stand on their own line</span>
  <span class="ruby-identifier">formatted</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/[ ]*([*]+) ([^*]*)/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;  #{$1} #{$2.strip}\n&quot;</span> }
  <span class="ruby-identifier">formatted</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-node">/[ ]*([#]+) ([^#]*)/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;  #{$1} #{$2.strip}\n&quot;</span> }

  <span class="ruby-identifier">formatted</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-format_paragraph">
            
              <b>format_paragraph</b>(text, len = 72, indent = 2)
            
            <a href="MailHelper.html#method-i-format_paragraph" name="method-i-format_paragraph" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns <code>text</code> wrapped at <code>len</code> columns and indented
<code>indent</code> spaces.</p>

<pre class="ruby"><span class="ruby-identifier">my_text</span> = <span class="ruby-string">'Here is a sample text with more than 40 characters'</span>

<span class="ruby-identifier">format_paragraph</span>(<span class="ruby-identifier">my_text</span>, <span class="ruby-value">25</span>, <span class="ruby-value">4</span>)
<span class="ruby-comment"># =&gt; &quot;    Here is a sample text with\n    more than 40 characters&quot;</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-format_paragraph_source')" id="l_method-i-format_paragraph_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/e2c7545cdd69376ed7e6ccb2084dda8cbd7571c2/actionmailer/lib/action_mailer/mail_helper.rb#L38" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-format_paragraph_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionmailer/lib/action_mailer/mail_helper.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">format_paragraph</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">len</span> = <span class="ruby-number">72</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-number">2</span>)
  <span class="ruby-identifier">sentences</span> = [[]]

  <span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">word</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">sentences</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">present?</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">sentences</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">word</span>]).<span class="ruby-identifier">join</span>(<span class="ruby-string">' '</span>).<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">len</span>
      <span class="ruby-identifier">sentences</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">word</span>]
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">sentences</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">word</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">sentences</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">sentence</span><span class="ruby-operator">|</span>
    <span class="ruby-node">&quot;#{&quot; &quot; * indent}#{sentence.join(' ')}&quot;</span>
  }.<span class="ruby-identifier">join</span> <span class="ruby-string">&quot;\n&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-mailer">
            
              <b>mailer</b>()
            
            <a href="MailHelper.html#method-i-mailer" name="method-i-mailer" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Access the mailer instance.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-mailer_source')" id="l_method-i-mailer_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/e2c7545cdd69376ed7e6ccb2084dda8cbd7571c2/actionmailer/lib/action_mailer/mail_helper.rb#L18" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-mailer_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionmailer/lib/action_mailer/mail_helper.rb, line 18</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">mailer</span>
  <span class="ruby-ivar">@_controller</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-message">
            
              <b>message</b>()
            
            <a href="MailHelper.html#method-i-message" name="method-i-message" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Access the message instance.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-message_source')" id="l_method-i-message_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/e2c7545cdd69376ed7e6ccb2084dda8cbd7571c2/actionmailer/lib/action_mailer/mail_helper.rb#L23" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-message_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionmailer/lib/action_mailer/mail_helper.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">message</span>
  <span class="ruby-ivar">@_message</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    